<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <!-- 引入layui 样式-->
    <link rel="stylesheet" href="../../static/layer/css/layui.css"/>
    <link rel="stylesheet" href="../../static/css/font-awesome.min.css">
    <script type="text/javascript" src="../../static/layer/layui.js"></script>
</head>
<body>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <!--<li class="layui-this">客户管理</li>-->
        <li class="layui-this">租户管理</li>
        <!--<button class="layui-btn customer_add AUTH-ZSGL_ZSXZ" style="float:right">
            <i class="layui-icon">&#xe608;</i> 新建客户
        </button>-->
    </ul>
    <div class="layui-tab-content" style="height: 100px;">
        <!--<div class="layui-tab-item layui-show">
            <table class="layui-table"
                   lay-data="{id:'zsgl',height: 'full-180',url:'/customer/list',page:true,limit:10,skin:'line', even:false, size:'lg'}"
                   lay-filter="zsgl">
                <thead>
                <tr>
                    <th lay-data="{checkbox:true}"></th>
                    <th lay-data="{space: true}"></th>
                    <th lay-data="{field:'CONTACT', width:120,event: 'setSign', style:'cursor: pointer;',sort: true}">
                        联系人
                    </th>
                    <th lay-data="{field:'CONTACT_TEL', width:120,event: 'setSign', style:'cursor: pointer;',sort: true}">
                        联系方式
                    </th>
                    <th lay-data="{field:'FIR_VISIT_DATE', width:135,event: 'setSign',sort: true,style:'cursor: pointer;'}">
                        初次来访时间
                    </th>
                 &lt;!&ndash;   <%&#45;&#45;<th lay-data="{field:'BUILDING_NAME', width:120,event: 'setSign',sort: true,style:'cursor: pointer;'}">
                    楼宇名称
                </th>
                    <th lay-data="{field:'ROOM_NUM', width:120,event: 'setSign',sort: true,style:'cursor: pointer;'}">
                        房间
                    </th>&#45;&#45;%>&ndash;&gt;
                    <th lay-data="{field:'ALL_WAY', width:120, event: 'setSign', style:'cursor: pointer;'}">
                        全部途径
                    </th>
                    <th lay-data="{field:'DEMAN_AREA', width:120,event: 'setSign', style:'cursor: pointer;',sort: true}">
                        需求面积
                    </th>
                    <th lay-data="{field:'FOLLOW_DATE', width:120,event: 'setSign', style:'cursor: pointer;',sort: true}">
                        跟进时间
                    </th>
                    <th lay-data="{field:'CUS_STATUS', width:120,event: 'setSign', style:'cursor: pointer;',sort: true}">
                        意向客户
                    </th>
                    <th lay-data="{field:'LEAS_CONS', width:120,event: 'setSign', style:'cursor: pointer;',sort: true}">
                        租赁顾问
                    </th>
                    <th lay-data="{fixed: 'right', width: 200, align: 'center', toolbar: '#barDemo'}">
                        操作
                    </th>
                    <th></th>
                </tr>
                </thead>
            </table>
           &lt;!&ndash; <script type="text/html" id="barDemo">&ndash;&gt;
                <div style="display: none;"  id="barDemo">
                    <a class="layui-btn layui-btn-primary layui-btn-mini AUTH-ZSGL_ZSCK" lay-event="detail">查看</a>

                    <a class="layui-btn layui-btn-mini AUTH-ZSGL_ZSBJ" lay-event="edit">编辑</a>

                <a class="layui-btn layui-btn-danger layui-btn-mini AUTH-ZSGL_ZSSC" lay-event="del">删除</a>
                    </div>
           &lt;!&ndash; </script>&ndash;&gt;
        </div>-->
        <div class="layui-tab-item layui-show">
            <table id="zhgl" lay-filter="zhgl"></table>
        </div>
        <!--<script type="text/html" id="zhglbar">-->
        <div style="display: none;" id="zhglbar">
            <a class="layui-btn layui-btn-primary layui-btn-mini AUTH-ZSGL_ZSCK" lay-event="detail">查看</a>
            <a class="layui-btn layui-btn-mini AUTH-ZSGL_ZSBJ" lay-event="edit">编辑</a>
        </div>
        <!--</script>-->
        <script type="text/html" id="zzTemp">
            {{#  if(d.CHECK_STATE != '01' && d.CHECK_STATE != '02' && d.CHECK_STATE != '03' && d.CHECK_STATE != '04' && d.CHECK_STATE != '2' && d.CHECK_STATE != '3' && d.CHECK_STATE != '4' && d.CHECK_STATE != '6' && d.CHECK_STATE != '7' && d.CHECK_STATE != '10' && d.CHECK_STATE != '12' && d.CHECK_STATE != '13' && d.CHECK_STATE != '14'){ }}
            <span class="layui-badge-dot layui-bg-green"></span> <span> 在租</span>
            {{#  } else { }}
            <span class="layui-badge-dot layui-bg-gray"></span> <span> 未在租</span>
            {{#  } }}
        </script>
    </div>
    <script>
        var table;
        layui.use(['jquery', 'table', 'form', 'layer', 'element'], function () {
            table = layui.table;
            var form = layui.form;
            $ = layui.jquery;
            element = layui.element;
            //获取 选中楼宇id
            var BUILDING_ID = QueryUtils.GetQueryString("activebuildingID");
            var BUSINESS_ID = QueryUtils.GetQueryString("activebusinessID");
            //监听表格复选框选择
            table.on('checkbox(business)', function (obj) {
                console.log(obj)
            });
            $(".customer_add").click(function () {
                layer.open({
                    type: 2,
                    title: '新建客户',
                    shadeClose: false,
                    shade: [0.3],
                    maxmin: true, //开启最大化最小化按钮
                    area: ['900px', '90%'],
                    scrollbar: false, //屏蔽滚动条
                    content: '../../../../webhtml/customer/Customer_add.html?'
                });
            });
            var data = {};
            data.BUILDING_ID = BUILDING_ID;
            data.BUSINESS_ID = BUSINESS_ID;
            //租客列表
            table.render({
                elem: '#zhgl'
                , url: '/customer/zhlist'
                , where: data
                , cols: [[ //标题栏
                    {checkbox: true, LAY_CHECKED: false} //默认全选
                    , {field: 'COMPANY_NAME', title: '公司名/租户名', width: 180}
                    , {field: 'BYNAME', title: '公司别名/租户别名', width: 180}
                    , {field: 'BUSINESS_LICENSE', title: '营业执照编号/身份证号', width: 180}
                    , {field: 'LEGAL_PERSON_NAME', title: '法人姓名', width: 120}
                    , {field: 'LEGAL_PERSON_TEL', title: '法人电话', width: 120}
                    , {field: 'SIGNER', title: '签订人', width: 120}
                    , {field: 'SIGNER_TEL', title: '签订人电话', width: 120}
                    , {field: 'CHECK_STATE', title: '是否在租', width: 130, templet: '#zzTemp'}
                    , {field: 'CONTRACT_ADDRESS', title: '通讯地址', width: 180}
                    , {fixed: 'right', width: 200, align: 'center', toolbar: '#zhglbar'}
                ]]
                , id: 'zhgl'
                , page: true
                , height: '567'
                , limit: '10'
            });

            //监听工具条  客户管理 编辑 删除 数据
            table.on('tool(zsgl)', function (obj) {
                var data = obj.data;
                if (obj.event === 'del') {
                    layer.confirm('确认删除 ' + data.CONTACT + ' 吗', {offset: '150px'}, function (index) {
                        layer.close(index);
                        $.ajax({
                            url: "/customer/delete",
                            data: {ID: data.ID, IS_DEL: 1},
                            dataType: "json",
                            type: "post",
                            async: false,
                            success: function (res) {
                                if (res.errcode === "0") {
                                    var index = parent.layer.getFrameIndex(window.name); // 先得到当前iframe层的索引
                                    //reloadTable();    // 表格刷新
                                    layer.msg(data.CONTACT + " 已删除", {offset: '150px'});   // 弹出删除成功
                                    //parent.reloadTablezs();// 父页面表格刷新
                                    reloadTablezs();
                                } else if (res.errcode === "1") {
                                    layer.msg(res.errmsg, function () {
                                    });
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                console.error(XMLHttpRequest.status);
                                console.error(XMLHttpRequest.readyState);
                                console.error(textStatus);
                            }
                        });
                    });
                } else if (obj.event === 'edit') {
                    layer.open({
                        type: 2,
                        title: "编辑 " + data.CONTACT,
                        shadeClose: false,
                        shade: [0.3],
                        maxmin: true, //开启最大化最小化按钮
                        area: ['900px', '90%'],
                        scrollbar: false, //屏蔽滚动条
                        content: '../../../../webhtml/customer/Customer_edit.html?type=edit&id=' + data.ID
                    });
                } else if (obj.event === 'detail') {
                    layer.open({
                        type: 2,
                        title: "查看 " + data.CONTACT,
                        shadeClose: false,
                        shade: [0.3],
                        maxmin: true, //开启最大化最小化按钮
                        area: ['900px', '90%'],
                        scrollbar: false, //屏蔽滚动条
                        content: '../../../../webhtml/customer/Customer_edit.html?type=detail&id=' + data.ID
                    });
                }
            });

            //监听工具条  租户管理 编辑 删除 数据
            table.on('tool(zhgl)', function (obj) {
                var data = obj.data;
                if (obj.event === 'del') {
                    layer.confirm('确认删除 ' + data.BYNAME + ' 吗', {offset: '150px'}, function (index) {
                        layer.close(index);
                        $.ajax({
                            url: "/customer/deltenant",
                            data: {ID: data.ID, IS_DEL: 1},
                            dataType: "json",
                            type: "post",
                            async: false,
                            success: function (res) {
                                if (res.errcode === "0") {
                                    var index = parent.layer.getFrameIndex(window.name); // 先得到当前iframe层的索引
                                    //reloadTable();    // 表格刷新
                                    layer.msg(data.BYNAME + " 已删除", {offset: '150px'});   // 弹出删除成功
                                    //parent.reloadTablezs();// 父页面表格刷新
                                    reloadTablezs();
                                } else if (res.errcode === "1") {
                                    layer.msg(res.errmsg, function () {
                                    });
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                console.error(XMLHttpRequest.status);
                                console.error(XMLHttpRequest.readyState);
                                console.error(textStatus);
                            }
                        });
                    });
                } else if (obj.event === 'edit') {
                    layer.open({
                        type: 2,
                        title: "编辑 " + data.BYNAME,
                        shadeClose: false,
                        shade: [0.3],
                        maxmin: true, //开启最大化最小化按钮
                        area: ['900px', '90%'],
                        scrollbar: false, //屏蔽滚动条
                        content: '../../../../webhtml/customer/Customer_edit_tenant.html?type=edit&id=' + data.ID + '&lease=' + data.LEASE
                    });
                } else if (obj.event === 'detail') {
                    layer.open({
                        type: 2,
                        title: "查看" + data.BYNAME,
                        shadeClose: false,
                        shade: [0.3],
                        maxmin: true, //开启最大化最小化按钮
                        area: ['900px', '90%'],
                        scrollbar: false, //屏蔽滚动条
                        content: '../../../../webhtml/customer/Customer_edit_tenant.html?type=detail&id=' + data.ID
                    });
                }
            });


        })
    </script>
    <script type="text/javascript" src="../../static/js/common/queryUtils.js"></script>
    <script type="text/javascript" src="../../static/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../static/js/common/authUtils.js"></script>
</div>
</body>
</html>